Conditions | 3 |
Total Lines | 12 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | export interface ValueMap { |
||
15 | |||
16 | public translate(key: string, valueMap: ValueMap = {}) { |
||
17 | 3 | if (this.language.hasOwnProperty(key)) { |
|
18 | 2 | let translated = String(this.language[key]); |
|
19 | 2 | for (let pattern in valueMap) { |
|
20 | 1 | translated = translated.replace(new RegExp('{' + pattern + '}', 'g'), valueMap[pattern]); |
|
21 | } |
||
22 | |||
23 | 2 | return translated; |
|
24 | } |
||
25 | |||
26 | 1 | return key; |
|
27 | } |
||
29 |